setResource
Type
function
Summary
Places data in a specified resource in a Mac OS file.
Syntax
setResource(<destinationFile>, <resourceType>,[<resID>],[<resName>], <flagsList>, <data>)
Description
Use the setResource function to create a resource or change its data.
If the destinationFile does not exist, the setResource function creates the file. If the destinationFile exists but has no resource fork, the setResource function creates the resource fork and copies the resource to it.
If the specified resource already exists, the setResource function replaces the data in the resource with the data. Otherwise, the setResource function creates the resource.
You must specify either a resID or resName or both. If you specify one but not the other, the setResource function looks for an existing resource with the specified name or ID, and replaces its contents without changing the existing ID or name.
The setResource function is most useful when used with the getResource function. Use the getResource function to obtain resource data, process it as desired, then use the setResource function to change the resource.
Resource data must be in the specific format appropriate to the resource type. If you set a resource to data that is incompatible with its resource type, you may damage the resource or the entire resource fork of the file. For information on the format of standard resource types, see Apple Computer's technical documentation, Inside Macintosh, located at http://developer.apple.com/techpubs/macos8/mac8.html.
Parameters
Name | Type | Description |
---|---|---|
destinationFile | The location and name of the file that contains the resource you want to set. If you specify a name but not a location, LiveCode assumes the file is in the defaultFolder. | |
resourceType | The 4-character type of the resources you want to change. | |
resID | integer | |
resName | string | |
flagsList | A list that can contain one or more flag characters. The possible resource flags are as follows:
The flags may be listed in any order. If a character is included, its corresponding resource flag is set to true. If the character is not included in the flagsList, its corresponding resource flag is set to false. If the flagsList is empty, all the flags are set to false. | |
data | Text or binary data, formatted appropriately for the resource type. |
Examples
setResource("Include","BNDL",129,"document",RL,the bundleData of me)
setResource(it,"ICON",128,,,getResource(it,"ICON",130))
Related
control structure: function
function: copyResource, getResource, getResources, result, deleteResource
glossary: resource fork, resource, Mac OS, return
Compatibility and Support
Introduced
LiveCode 1.1
OS
mac
Platforms
desktop